<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改车辆-信息')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-info-edit" th:object="${carInfo}">
            <input name="carInfoId" th:field="*{carInfoId}" type="hidden">
            <input name="carId" th:field="*{carId}" type="hidden">
            <input name="menuId" th:field="*{menuId}" type="hidden">
            <input name="configType" th:field="*{configType}" type="hidden">
            <input id="car_info" name="info" th:field="*{info}" type="hidden">
            <div class="form-group" th:if="${carInfo.carInfoId!=null}">
                <label class="col-sm-2 control-label">图片</label>
                <div class="col-sm-10" th:include="system/common/file_upload :: multiple_img(_file_id='multipleFile',_file_type='img',_file_list=${@file.getFiles(carInfo.carId,carInfo.configType)})"/>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">整车重量数据（单位kg）</h3>
                </div>
                <div class="panel-body">
                    <span class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">整备质量：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.curbWeight" th:field="*{infoMap.curbWeight}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">满载质量：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.fullLoadQuality" th:field="*{infoMap.fullLoadQuality}" class="form-control" type="text"/>
                            </div>
                        </div>
                    </span>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">轴荷分配（整备质量状态下）</h3>
                </div>
                <div class="panel-body">
                    <span class="form-horizontal" role="form">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">左前轴承重：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.leftFrontBearingWeight" th:field="*{infoMap.leftFrontBearingWeight}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">左后轴承重：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.leftRearBearingWeight" th:field="*{infoMap.leftRearBearingWeight}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">右前轴承重：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.rightFrontBearingWeight" th:field="*{infoMap.rightFrontBearingWeight}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">右后轴承重：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.rightRearBearingWeight" th:field="*{infoMap.rightRearBearingWeight}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">前轮承重：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.frontWheelLoad" th:field="*{infoMap.frontWheelLoad}" class="form-control" type="text"/>
                            </div>
                            <label class="col-sm-2 control-label">后轮承重：</label>
                            <div class="col-sm-2">
                                <input name="infoMap.rearWheelLoad" th:field="*{infoMap.rearWheelLoad}" class="form-control" type="text"/>
                            </div>
                        </div>
                    </span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-8"><button type="button" class="btn btn-success" onclick="submitHandler()">上传</button></div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/car/info";
        $("#form-info-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                let json=$('#form-info-edit').serializeJson();
                console.log(json)
                $('#car_info').val(JSON.stringify(json.infoMap)||'{}');
                let serialize = $('#form-info-edit').serialize();
                console.log(serialize)
                // console.log(JSON.stringify($('#form-info-edit').serializeJson()))
                // return;
                $.operate.save(prefix + "/edit?_="+Math.random(), serialize);
            }
        }
        $(function (){
            multipleFile_manager.init({busId: [[${carInfo.carId}]], busType: [[${carInfo.configType}]], fileType: 'img'});
        });
    </script>
</body>
</html>